import socket


def func1():
    my = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    my.connect(('8.8.8.8', 80))
    ip = my.getsockname()
    print(ip[0])
    my.close()


def func2():
    my_addr = socket.gethostbyname(socket.gethostname())
    print(my_addr)


if __name__ == '__main__':
    func1()
    func2()